<template>
  <div class="layui-layout layui-layout-admin">
    <div class="adminnav1">
      <Pagetop></Pagetop>
    </div>
    <div class="adminnav2">
      <Secondnav urlname="retail"></Secondnav>
    </div>

    <!-- 主体内容 -->
    <div class="layui-body kedou-admin" id="LAY_app_body app">
      <div class="layadmin-tabsbody-item layui-show">
        <div class="pagelist">
          <div class="layui-card-body">
            <fieldset class="layui-elem-field layui-field-title">
              <legend>分账用户信息</legend>
            </fieldset>
          </div>

          <div class="layui-card-body">
            <div class="buttop">
            </div>
            <Tables :fdate="pdate" :result="res" height="430" :totalCount="totalRows" :pageNumber="curindex"
              :fbtn="btn"></Tables>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Pagetop from "../common/pagetop.vue";
import Secondnav from "../common/secondnav.vue";
import Tables from "../common/tables.vue";
import Search from "../common/search.vue";
export default {
  name: "promoterorderdetail",
  components: { Pagetop, Secondnav, Tables, Search },
  data () {
    return {
      id: "",
      pdate: [], //表头
      res: "", //内容
      totalRows: "", //总数量
      curindex: 0, //页数
      btn: [], //按钮
      searchArr: [], //搜索
      isShow: false,
      seapram: "",
      type: localStorage.getItem("type")
    };
  },
  mounted () {
    this.getdate();
    this.getsearch();
    this.id = this.$route.query.id;
  },
  methods: {
    getdate: function () {
      var _this = this;
      this.id = this.$route.query.id;
      var url = "/retail/bapi/v1.9/share-orders/shareOrdersUserList/" + this.$route.query.id;


      if (_this.seapram) {
        var dates = {
          size: pageSize,
          page: _this.curindex
        };
        var res = _this.seapram;
        for (var i = 0; i < res.length; i++) {
          dates[res[i].key] = res[i].val;
        }
      } else {
        var dates = {
          size: pageSize,
          page: _this.curindex
        };
      }
      //alert(url+"//"+JSON.stringify(dates))
      ajaxRequest(url, "GET", "json", dates, function (ret, err) {
        //alert(url+"//"+JSON.stringify(ret))
        var arr = [];
        arr[0] = [
          { field: "id", title: "id", width: '12%' },
          {
            field: "accountName",
            title: "分账用户账号",
            width: '12%'
          },
          {
            field: "subLedgerAmount",
            title: "分账金额",
            width: '8%',
            templet: function (d) {
              return d.subLedgerAmount/100;
            }
          },
          {            field: 'settlementStatus', title: '结算状态', width: '8%', templet: function (d) {
              if (d.settlementStatus == 'WAITSETTLE') return '待结算'
              else if (d.settlementStatus == 'HASBEENSETTLED') return '已完成'
              else if (d.settlementStatus == 'REFUND') return '已退款'
              else return ''
            }          },


          {
            field: "accountName",
            title: "订单用户名称",
            width: '12%',
            templet: function (d) {
              return d.shareOrders.accountName;
            }
          },
          {
            field: "amount",
            title: "订单金额",
            width: '8%',
            templet: function (d) {
              return d.shareOrders.amount/100;
            }
          },
          {
            field: "subLedgerNum ",
            title: "分账人数",
            width: '8%',
            templet: function (d) {
              return d.shareOrders.subLedgerNum;
            }
          },
          { field: 'settlementAt', title: '结算时间', width: '16%', templet: function (d) { return FormatDate(d.settlementAt, 3) } }
          ,
           { field: 'createAt', title: '创建时间', width: '16%', templet: function (d) { return FormatDate(d.createAt, 3) } }
          ,

        ];
        _this.pdate = arr;
        _this.res = ret.data;
        _this.totalRows = ret.data.totalRows;
        _this.curindex = ret.data.page + 1;
      });
    },
    getsearch: function () {
      var arr = [{ field: "id", title: "ID", type: "input" }];
      this.searchArr = arr;
    },
    page: function (index, obj) {
      this.curindex = index;
      this.getdate();
    },
    sousuo: function (pram) {
      this.seapram = pram;
      this.res = "";
      this.totalRows = "";
      this.curindex = 1;
      this.getdate();
    },
    screens: function () {
      return screen();
    }
  },
  updated: function () {
    this.isShow = true;
    layui.use("form", function () {
      var form = layui.form;
      form.render();
    });
  }
};
</script>
<style scoped>
/**/
</style>